<?php
session_start();
date_default_timezone_set('PRC');
//var_dump($_POST);exit;

$planId = $_POST['planId'];
$userId = '';
if($_SESSION['id']==null){
	$error='请登录';
}else{
	$userId = $_SESSION['id'];
}





//将内容插入到数据库中
if(empty($error)){
	include 'config.php';
	$link=mysql_connect(HOST,DBUSER,DBPASS) or die('数据库连接失败');
	mysql_select_db(DBNAME,$link);
	mysql_set_charset('utf8');

	if(empty($error)){
		$sql= "INSERT INTO t_book (userId,planId,createdate)
			VALUES('".$userId."','".$planId."','".date('Y-m-d')."')";
		$result=mysql_query($sql);
		$tid=mysql_insert_id();
		if($tid<=0){
			$error=$sql.$tid.'插入数据库失败!';
		}
	}
	mysql_close($link);
}
//错误跳转
if(empty($error)){
	header('Location:travelList.php');
}else{
	header('Location:travelDetailed.php?id='.$planId.'&error='.$error);
}
ob_end_flush();
?>
